/*
 * trdp_mini.h
 *
 *  Created on: 2016年12月20日
 *      Author: think
 */

#ifndef API_TRDP_MINI_H_
#define API_TRDP_MINI_H_

#include "trdp_mini_config.h"
#include "trdp_mini_types.h"

#ifdef __cplusplus
extern "C" {
#endif

/**********************************************************************************************************************/
/**    Callback for receiving indications, timeouts, releases, responses.
 *
 *  @param[in]    *comId   	 data resource's comId
 *  @param[in]    resultCode callback's result code number that indicate the callback function's target
 *  @param[in]    *pData     pointer to received data
 *  @param[in]    dataSize   size of received data pointer to received data
 */
typedef TRDP_MINI_ERR_T (*TRDP_MINI_PD_CALLBACK_T)(
	void 					*arg,
    INT32U                  comId,
    INT8U					*pData,
    INT32U                  dataSize,
	INT8U					*recvIP,
	INT16U					recvPort,
	TRDP_MINI_ERR_T			errCode);


/**********************************************************************************************************************/
/**    Callback for receiving indications, timeouts, releases, responses.
 *
 *  @param[in]    appHandle  handle returned also by tlc_init
 *  @param[in]    *pRefCon   pointer to user context
 *  @param[in]    *pMsg      pointer to received message information
 *  @param[in]    *pData     pointer to received data
 *  @param[in]    dataSize   size of received data pointer to received data
 */
typedef TRDP_MINI_ERR_T (*TRDP_MINI_MD_CALLBACK_T)(
	void 					*arg,
	INT32U                  comId,
	MD_ACTION_T				action,
    INT8U                   *pData,
    INT32U                  dataSize,
	INT32U  				etbTopoCnt,
	INT8U   				*pSessionID,
	INT8S   				*pSrcURI,
	INT8S   				*pDestURI,
	INT32U  				seqCnt,
	INT8U					*recvIP,
	INT16U					recvPort,
	TRDP_MINI_ERR_T			errCode);

//------------------------API--------------------------------------------------------------------------------
TRDP_MINI_ERR_T trdp_mini_init_so(INT8U ifCnt, INT8U mcCnt, const char * ifAddress[],  const char * mcAddress[], INT8U qos, INT8U ttl, COM_TYPE_T comType);
TRDP_MINI_ERR_T	trdp_mini_init(void);
TRDP_MINI_ERR_T trdp_mini_pd_prepare(INT32U comId, INT8U *pData, INT32U dataSize, INT8U *pSrcIP, INT8U *pDestIP,
									 INT32U etbTopoCnt, INT32U interval, COM_TYPE_T comType);
TRDP_MINI_ERR_T trdp_mini_pd_put(INT32U comId, INT8U *pData, INT32U dataSize, INT8U *pSrcIP, INT8U *pDestIP);
TRDP_MINI_ERR_T trdp_mini_pd_update(INT32U comId, INT8U *pData, INT32U dataSize, INT8U *pDestIP);
TRDP_MINI_ERR_T trdp_mini_pd_unprepare(INT32U comId, INT8U *pDestIP);
TRDP_MINI_ERR_T trdp_mini_pd_chageSeqID(INT32U comId, INT32U seqID);
TRDP_MINI_ERR_T trdp_mini_pd_activateRed(void);
TRDP_MINI_ERR_T trdp_mini_pd_deactivateRed(void);
TRDP_MINI_ERR_T trdp_mini_pd_request(INT32U comId,  INT8U *pData, INT32U dataSize, INT8U *pSrcIP, INT8U *pDestIP,
									INT32U etbTopoCnt, INT32U timeOut,COM_TYPE_T comType, TRDP_MINI_PD_CALLBACK_T pUserCallBack);
TRDP_MINI_ERR_T trdp_mini_pd_subscribe(INT32U comId, INT8U *pSrcIP, INT8U *pDestIP, COM_TYPE_T comType, TRDP_MINI_PD_CALLBACK_T pUserCallBack);
TRDP_MINI_ERR_T trdp_mini_pd_unsubscribe(INT32U comId);
TRDP_MINI_ERR_T trdp_mini_pd_poll(INT32U comId, INT8U *pData, INT32U *dataSize, INT8U *pDestIP);
void trdp_mini_Receive_CallBack(void *arg, INT8U *pData, INT32U dataSize, INT8U *pRecvIp, INT16U recvPort);
TRDP_MINI_ERR_T trdp_mini_md_request(INT32U comId,  INT8U *pData, INT32U dataSize, INT8U *pSrcIP, INT8U *pDestIP, INT32U etbTopoCnt,
									INT32U timeOut, BOOLEAN needReply,INT8S *srcURI, INT8S *destURI, TRDP_MINI_MD_CALLBACK_T pUserCallBack);
TRDP_MINI_ERR_T trdp_mini_md_confirm(INT32U comId, INT8U *pSrcIP, INT8U *pDestIP, INT32U etbTopoCnt,INT8S *srcURI, INT8S *destURI,
									INT8U *pSessionId, INT32U replyStatus, INT32U seqCnt);
TRDP_MINI_ERR_T trdp_mini_md_reply(INT32U comId,  INT8U *pData, INT32U dataSize, INT8U *pSrcIP, INT8U *pDestIP, INT32U etbTopoCnt,
									INT32U timeOut, BOOLEAN needConfirm,INT8S *srcURI, INT8S *destURI,INT8U *pSessionId,
									INT32U replyStatus, INT32U seqCnt, TRDP_MINI_MD_CALLBACK_T pUserCallBack);
TRDP_MINI_ERR_T trdp_mini_md_abort(INT32U comId);
TRDP_MINI_ERR_T trdp_mini_md_addListener(INT32U comId, INT8U *pSrcIP, INT8U *pDestIP, TRDP_MINI_MD_CALLBACK_T pUserCallBack);
TRDP_MINI_ERR_T trdp_mini_md_removeListener(INT32U comId);
void trdp_mini_process(void);
BOOLEAN trdp_mini_until_isBigEndian(void);
INT32U trdp_mini_until_RvINT32U(INT32U value);
INT16U trdp_mini_until_RvINT16U(INT16U value);
TRDP_MINI_ERR_T trdp_mini_delay(INT32U delay);
double trdp_mini_getTick(void);

#ifdef __cplusplus
}
#endif

#endif /* API_TRDP_MINI_H_ */
